package tt.love.hw.common;

import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import tt.love.hw.UserSessionInfo;

public class ActionContext {
	private HttpServletRequest request;
	private HttpServletResponse response;

	private Map<String, Object> actionContextMap = new ConcurrentHashMap<String, Object>();

	public void put(String key, Object value) {
		actionContextMap.put(key, value);
	}

	public Object get(String key) {
		return actionContextMap.get(key);
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public void setResponse(HttpServletResponse response) {
		this.response = response;
	}

	public Iterator<String> keyIterator() {
		return actionContextMap.keySet().iterator();
	}
	
	public UserSessionInfo getUserSessionInfo(){
		return (UserSessionInfo)request.getSession().getAttribute("USI");
	}

	public ActionContext(HttpServletRequest req, HttpServletResponse resp) {
		this.request = req;
		this.response = resp;
	}
	
	public Map<String, Object> getMap(){
		return actionContextMap;
	}

}
